package Client.View;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;


public class MyChatPane extends JScrollPane{

	/**
	 * 
	 */
	private static final long serialVersionUID = 5666714762003829426L;
	private JPanel panel;
	private Font nameFont;
	
	public MyChatPane(int width, int height) {
		
		this.setPreferredSize(new Dimension(width, height));
		
		this.setBackground(LoginFrame.DEFAULT_BG_COLOR);
		
		panel = new JPanel();
		panel.setBackground(LoginFrame.DEFAULT_BG_COLOR);
		panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
		setViewportView(panel);
		setVerticalScrollBarPolicy(VERTICAL_SCROLLBAR_AS_NEEDED);
	
		
	}
	
	public void addNotification(int type, String string){
		
		Font notificationFont = new Font("Arial", Font.ITALIC, 13);
		
		JLabel lbl = new JLabel();
		
		lbl.setFont(notificationFont);
		lbl.setForeground(Color.GRAY);

		switch (type){
		
		case 1:
			lbl.setText("O utilizador " + string + " entrou na sala");
			break;

		case 2:
			lbl.setText("O utilizador " + string + " saiu da sala");
			break;

		}

		panel.add(lbl);
		
		
	}
	
	public void addMessage(String from, String msg){

		nameFont = new Font("Arial", Font.BOLD, 13);
		
		JLabel lbl = new JLabel();
			 
		lbl.setText(from + " diz: " + msg);
		lbl.setFont(nameFont);

		panel.add(lbl);
	}
	
}